package com.khyr.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.khyr.Vo.DoctorAssessmentVo;
import com.khyr.Vo.InsertCommentVo;
import com.khyr.entity.Comment;
import com.khyr.entity.HisPatient;
import com.khyr.feign.UserFeign;
import com.khyr.service.DoctorAssessmentService;
import com.khyr.vo.R;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 宋一恒
 * @version 1.0
 */
@RestController
@RequestMapping("/accountant/raes/statistics/comment")
public class DoctorAssessmentController {
    @Autowired
    private HttpServletRequest request;
    @Autowired
    private UserFeign userFeign;
    @Autowired
    private DoctorAssessmentService doctorAssessmentService;

    // 查询所有的评论
    @PostMapping("/queryAllNew")
    public R<Page<Comment>> queryAllNew(@RequestBody DoctorAssessmentVo doctorAssessmentVo) {
        return doctorAssessmentService.queryAllNew(doctorAssessmentVo);
    }

    //删除评论
    @DeleteMapping("/deleteNewByIds/{ids}")
    public R<Integer> deleteNewByIds(@PathVariable List<Long> ids) {
        return doctorAssessmentService.deleteNewByIds(ids);
    }
    /**
     * @create by: Zr
     * @description: 根据医生id查询评论
     * @create time: 2025/3/18 15:58
     * @param id
     * @return com.khyr.vo.R<java.util.List<com.khyr.entity.Comment>>
     */
    @GetMapping("/getUserCommentByIdQ/{id}")
    public R<List<Comment>> getUserCommentById(@PathVariable Long id) {
        return doctorAssessmentService.getUserCommentById(id);
    }
    /**
     * @create by: Zr
     * @description: 患者对医生评论
     * @create time: 2025/3/19 15:36
     * @param insertCommentVo
     * @return com.khyr.vo.R<java.lang.String>
     */
    @PostMapping("/insertComment")
    public R<String> insertComment(@RequestBody InsertCommentVo insertCommentVo) {
        String token = request.getHeader("token");
        // 获取当前登录者的信息
        HisPatient patient=userFeign.getPatientInfo(token).getData();
        return doctorAssessmentService.insertComment(insertCommentVo,patient);
    }

}
